

<%@ page import="edu.nps.sats.domain.FlightInstance" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'flightInstance.label', default: 'FlightInstance')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.edit.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${flightInstanceInstance}">
            <div class="errors">
                <g:renderErrors bean="${flightInstanceInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" >
                <g:hiddenField name="id" value="${flightInstanceInstance?.id}" />
                <g:hiddenField name="version" value="${flightInstanceInstance?.version}" />
                <div class="dialog">
                    <table>
                        <tbody>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="airplane"><g:message code="flightInstance.airplane.label" default="Airplane" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'airplane', 'errors')}">
                                    <g:select name="airplane.id" from="${edu.nps.sats.domain.Airplane.list()}" optionKey="id" optionValue="number" value="${flightInstanceInstance?.airplane?.id}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="arrivalTime"><g:message code="flightInstance.arrivalTime.label" default="Arrival Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'arrivalTime', 'errors')}">
                                    <g:datePicker name="arrivalTime" noSelection="['':'-Choose-']" precision="minute" value="${flightInstanceInstance?.arrivalTime}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="departureTime"><g:message code="flightInstance.departureTime.label" default="Departure Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'departureTime', 'errors')}">
                                    <g:datePicker name="departureTime" noSelection="['':'-Choose-']" precision="minute" value="${flightInstanceInstance?.departureTime}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="flight"><g:message code="flightInstance.flight.label" default="Flight" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'flight', 'errors')}">
                                    <g:select name="flight.id" from="${edu.nps.sats.domain.Flight.list()}" optionKey="id" optionValue="id" value="${flightInstanceInstance?.flight?.id}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="flightStatus"><g:message code="flightInstance.flightStatus.label" default="Flight Status" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'flightStatus', 'errors')}">
                                    <g:select name="flightStatus" from="${edu.nps.sats.domain.FlightStatus?.values()}" keys="${edu.nps.sats.domain.FlightStatus?.values()*.name()}" value="${flightInstanceInstance?.flightStatus?.name()}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="reservationSet"><g:message code="flightInstance.reservationSet.label" default="Reservation Set" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'reservationSet', 'errors')}">

<ul>
<g:each in="${flightInstanceInstance?.reservationSet?}" var="r">
    <li><g:link controller="reservation" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="reservation" action="create" params="['flightInstance.id': flightInstanceInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'reservation.label', default: 'Reservation')])}</g:link>

                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="scheduledArrivalTime"><g:message code="flightInstance.scheduledArrivalTime.label" default="Scheduled Arrival Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'scheduledArrivalTime', 'errors')}">
                                    <g:datePicker name="scheduledArrivalTime" precision="minute" value="${flightInstanceInstance?.scheduledArrivalTime}"  />
                                </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="scheduledDepartureTime"><g:message code="flightInstance.scheduledDepartureTime.label" default="Scheduled Departure Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: flightInstanceInstance, field: 'scheduledDepartureTime', 'errors')}">
                                    <g:datePicker name="scheduledDepartureTime" precision="minute" value="${flightInstanceInstance?.scheduledDepartureTime}"  />
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
